/**
 * Created by zzy on 2017/9/26.
 */
import React, {Component} from 'react';
import {
    AppRegistry,
    Text,
    View,
    PixelRatio,
    TouchableOpacity,
    Image,
    Dimensions,
} from 'react-native';
import Icon from 'react-native-vector-icons/Ionicons'
import DataUtil from '../util/DataUtil'

let {width,height} = Dimensions.get('window');

export default class ProductCellH extends Component{
    render(){
        let {name,showPrice,soldNumber,imageUrl,volume} = this.props.item;
        let {currentPrice,saleMount} = this.props.item.productItemModels[0];
        let {addToShoppingCart,callback} = this.props;
        return <TouchableOpacity style={[{backgroundColor:'#f5f5f5',width:width/2,padding:2}]} onPress={callback} activeOpacity={0.9}>
            <View style={{flexDirection:'column',backgroundColor:'white',height:220}}>
                <Image style={{width:width/2,height:150,resizeMode:'contain'}} source={{uri:imageUrl}}/>
                <Text numberOfLines={1} style={{fontWeight:'100',marginLeft:10,color:'black',fontSize:14}}>{name+volume}</Text>
                <Text style={{color:'red',marginLeft:10,fontSize:13,marginTop:5}}>¥{DataUtil.f2y(currentPrice)}</Text>
                <View style={{flexDirection:'row',justifyContent:'space-between',alignItems:'center'}}>
                    <View style={{flexDirection:'row',marginLeft:10}}>
                        <View style={{ borderWidth: 1 / PixelRatio.get(),borderColor: 'red',width:30}}>
                            <Text style={{fontSize: 10,color: 'red',textAlign: 'center',}}>自营</Text>
                        </View>
                        <Text style={{fontSize:12,color:'gray',marginLeft:2}}>已售{saleMount+''}</Text>
                    </View>
                    <TouchableOpacity style={{marginRight:10}} onPress={()=>{
                        addToShoppingCart(this.props.item)
                    }}>
                        <Icon name="ios-cart-outline" size={24} color="red"/>
                    </TouchableOpacity>
                </View>

            </View>
        </TouchableOpacity>
    }
}